/*
 * OpenView.java
 *
 * Created on June 5, 2006, 10:14 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author Timoz
 */
import java.io.*;
import java.util.*;
import java.awt.*;

public class OpenView {
    static FileInputStream fis;
    static ObjectInputStream ois;
    /** Creates a new instance of OpenView */
    public OpenView() {
    }
    
    public static void openView(String formTitle) {
        String curDir = System.getProperty("user.dir");
        try {
            fis = new FileInputStream(curDir+"/Forms/"+MainWindow.host+"/"+MainWindow.selectedDatabase+"/"+formTitle);
            ois = new ObjectInputStream(fis);
            Dimension panelDimension=(Dimension)ois.readObject();
            Color panelBackgroundColor = (Color)ois.readObject();
            ArrayList<MyComponentContainer> componentList = (ArrayList<MyComponentContainer>)ois.readObject();
            fis.close();
            ois.close();
            OutputPanel outputPanel = new OutputPanel (MainWindow.dbCon,componentList, panelBackgroundColor, panelDimension, MainWindow.recordsLimit);
            MainPanel mainPanel = new MainPanel (outputPanel.compPanel);
            outputPanel.compPanel.setLocation(0,0);
            mainPanel.drawPanel.add(outputPanel.compPanel);
            mainPanel.insertRecordNavigationMenu (outputPanel);
            OutputFrame outputFrame = new OutputFrame (mainPanel);
            outputFrame.refreshScrolls();
            outputFrame.setTitle(formTitle);
            outputFrame.setVisible(true);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
